{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sdm import Bitstring\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "bits = 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "distances = []\n",
    "for _ in range(10000):\n",
    "    v1 = Bitstring.init_random(bits)\n",
    "    v2 = Bitstring.init_random(bits)\n",
    "    \n",
    "    a = Bitstring.init_random(bits)\n",
    "    b = a.copy()\n",
    "    b.flip_random_bits(800)\n",
    "    \n",
    "    chunck_a = a ^ v1\n",
    "    chunck_b = b ^ v2\n",
    "    \n",
    "    dist = chunck_a.distance_to(chunck_b)\n",
    "    distances.append(dist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "500.079\n"
     ]
    }
   ],
   "source": [
    "print(1.0*sum(distances)/len(distances))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvFvnyVgAAEQVJREFUeJzt3X+MpVV9x/H3RxBsrXX5sW62u5suLWus/aNKRqRRU5RoEYxLGkWaRre47cYWWyumFu0fTZs2AU3EkjSYjVAXqwWiEjaIVopaYxqQQQFFVEYKYbfAroi0hEiDfPvHPchlmd25s3Nn79zD+5Vs7nnOc+bec/LsfObMeX5MqgpJUr+eM+kOSJKWl0EvSZ0z6CWpcwa9JHXOoJekzhn0kt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jN3fWPZpczdPnYydxuPyLgbn6GCwjHNv6/+Sj8s0zegX6xLgk0nmgB8zCJWV7nzgU0neCzzCU0sd1zK4imAOeJTB1TkrVg0eg/HHwGfbrOQhBmvBsPKPyxrgqjZDPBz4dFV9MclNDH6V3srg6o4zW/uVfGz2N5Y5BqFxXdt3Q1W9q6puT3Ilgx8CjwPnVNXPJtT3fc07lgO0n8bjcgRwaZLvAP8HbKlB6i/5uHhnrCR1btquupEkLZJBL0mdM+glqXMGvSR1zqCXpM4Z9JLUOYNekjpn0EtS5/4ffHLRi6LMRjwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.hist(distances, bins='fd');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
